<?php

namespace app\merchant\controller;

use app\merchant\model\Store as StoreModel;

/**
 * 后台首页
 * Class Index
 * @package app\store\controller
 */
class Index extends Base
{


    /**
     * 判断权限接口
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function checkAuth()
    {
        $param = $this->postData();
        // 控制器名称
        $controller = toUnderScore($param['controller']);
        // 方法名称
        $action = toUnderScore($param['action']);

        if(!$this->checkHasAuth($controller,$action)){
            return $this->renderError([],"很抱歉，没有访问权限");
        }else{
            return $this->renderSuccess([],"有访问权限");
        }

    }

    /**
     * 后台首页--商城统计，今日，本月，动态订单，商品销售榜单，用户销售榜单
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $param = $this->postData();

        $model = new StoreModel;
        $data = $model->getHomeData($param);

        return $this->renderSuccess($data);

    }


    /**
     * 后台首页--实时数据概况
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function online()
    {
        $param = $this->postData();

        $model = new StoreModel;
        $data = $model->online($param);

        return $this->renderSuccess($data);

    }


    /**
     * 后台首页--用户访客数量
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function userVisitor()
    {
        $param = $this->postData();

        $model = new StoreModel;

        $data = $model->userVisitor($param);

        return $this->renderSuccess($data);


    }


    /**
     * 后台首页--交易走势
     * @return mixed
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function echarts()
    {
        $param = $this->postData();

        $model = new StoreModel;

        $data = $model->echarts($param);

        return $this->renderSuccess($data);


    }
    
    


}
